<?php

namespace app\controller;

use app\BaseController;
use app\Qrcode;

class QrcodeFiles extends BaseController
{
    public function setCode()
    {
        $codes = $this->request->param("code");
        $qrcode = $this->app->make(Qrcode::class);
        $code = $qrcode->createQrcode(env('QRCODE_URL') . $codes, 220);
        $label = $qrcode->createLabel($codes);
        return $qrcode->files($code, null, $label);
    }

    public function getMerchantCode()
    {
        $code = $this->request->param("code");
        $qrcode = $this->app->make(Qrcode::class);
        $codes = $qrcode->createQrcode($this->request->domain() . "/merchant/register/" . $code, 220);
        $label = $qrcode->createLabel($code);
        return $qrcode->files($codes, null, $label);
    }
}
